package _12_proxy_pattern.v_dynamic_proxy.dynamic_common;

import java.lang.reflect.InvocationHandler;

/**
 * @Description: 具体业务的动态代理
 * @Auther: 2019/6/19 18:35 by zhang.jy
 */
public class SubjectDynamicProxy extends DynamicProxy {
	public static <T> T newProxyInstance(Subject subject) {
		//获得ClassLoader
		ClassLoader loader = subject.getClass().getClassLoader();
		//获得接口数组
		Class<?>[] classes = subject.getClass().getInterfaces();
		//获得handler
		InvocationHandler handler = new MyInvocationHandler(subject);
		return newProxyInstance(loader, classes, handler);
	}
}